package Filter;

import Filter.impl.FemaleCriteria;
import Filter.impl.MaleCriteria;
import Filter.impl.SingleCriteria;
import Filter.impl.AndCriteria;
import Filter.entity.Person;
import Filter.service.Criteria;
import com.google.gson.Gson;

import java.util.ArrayList;
import java.util.List;

/**
 * @author chengjunjie
 * @date 2025-09-10
 */

public class FilterDemo {
    public static void main(String[] args) {
        List<Person> list = new ArrayList<>();

        list.add(new Person("张三", "男", "单身"));
        list.add(new Person("李四", "女", "恋爱中"));
        list.add(new Person("王五", "男", "已婚"));
        list.add(new Person("赵六", "女", "单身"));
        list.add(new Person("孙七", "男", "单身"));
        list.add(new Person("周八", "女", "已婚"));

        Criteria male = new MaleCriteria();
        Criteria female = new FemaleCriteria();
        Criteria single = new SingleCriteria();
        Criteria singleMale = new AndCriteria(single, male);

        System.out.println("女性："+new Gson().toJson(female.filter(list)));

        System.out.println("男性："+new Gson().toJson(male.filter(list)));

        System.out.println("单身男性："+new Gson().toJson(singleMale.filter(list)));

    }

}
